package com.luofan.controller;


import com.luofan.common.result.Result;
import com.luofan.common.result.ResultCodeEnum;
import com.luofan.entity.po.Collect;
import com.luofan.entity.vo.CollectUserVO;
import com.luofan.entity.vo.CollectVO;
import com.luofan.entity.vo.TeacherCollectVO;
import com.luofan.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 档案收集任务表 前端控制器
 * </p>
 *
 * @author 
 * @since 2025-03-26
 */
@RestController
@RequestMapping("/collect")
public class CollectController {

    @Autowired
    private CollectService collectServiceSer;

    //教研室主任 发布档案收集任务
    @PostMapping
    public Result<String> saveCollect(@RequestBody Collect collect) {
        ResultCodeEnum resultCodeEnum = collectServiceSer.saveCollect(collect);
        return Result.build(null, resultCodeEnum);
    }

    //根据教研室id和学期id获取所有对应的档案收集任务信息
    @GetMapping("/{sectionId}/{termId}")
    public Result<List<CollectVO>> listCollectBySectionIdAndTermId(@PathVariable Long sectionId,
                                                                   @PathVariable Long termId) {
        List<CollectVO> collectList = collectServiceSer.listCollectBySectionIdAndTermId(sectionId, termId);
        return Result.ok(collectList);
    }

    //根据档案收集任务id获取其档案收集任务提交情况
    @GetMapping("/completion/{collectId}")
    public Result<CollectUserVO> listCollectCompletion(@PathVariable Long collectId) {
        CollectUserVO collectUserVO = collectServiceSer.listCollectCompletion(collectId);
        return Result.ok(collectUserVO);
    }

    //根据教师id和学期id获取收到的档案收集任务
    @GetMapping("/teacher/{userId}/{termId}")
    public Result<List<TeacherCollectVO>> listCollectByUserId(@PathVariable Long userId,
                                                              @PathVariable Long termId) {
        List<TeacherCollectVO> collectList = collectServiceSer.listCollectByUserId(userId, termId);
        return Result.ok(collectList);
    }

}
